home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / rcs / number.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.7 KB  |  186 lines

  1. head    1.3;
  2. access;
  3. symbols;
  4. locks
  5.     dlorre:1.3; strict;
  6. comment    @// @;
  7.  
  8.  
  9. 1.3
  10. date    97.07.14.04.23.01;    author dlorre;    state Exp;
  11. branches;
  12. next    1.2;
  13.  
  14. 1.2
  15. date    96.08.28.20.04.53;    author dlorre;    state Exp;
  16. branches;
  17. next    1.1;
  18.  
  19. 1.1
  20. date    96.08.22.02.05.10;    author dlorre;    state Exp;
  21. branches;
  22. next    ;
  23.  
  24.  
  25. desc
  26. @Oui.lib -- Object User Interface
  27. Projet créé en 1994
  28. Auteur: Dominique Lorre
  29. @
  30.  
  31.  
  32. 1.3
  33. log
  34. @font is now used
  35. @
  36. text
  37. @// $Id$
  38. #include <exec/lists.h>
  39. #include <intuition/imageclass.h>
  40. #include <intuition/gadgetclass.h>
  41. #include <libraries/gadtools.h>
  42. #include <mydebug.h>
  43.  
  44. #include "gadgets/number.h"
  45. #include "gadgetlist.h"
  46. #include "window.h"
  47. #include "screen.h"
  48.  
  49.  
  50. // ========================================================================
  51. // ==========================  NUMBER CLASS ===============================
  52. // ========================================================================
  53.  
  54. number::number(gadgetlist *gl,
  55.                void (window::*func)(gadget *, unsigned long, unsigned short),
  56.                const char *title,
  57.                long val,
  58.                long max,
  59.                unsigned long flags,
  60.                unsigned long justify) : gadget(gl, func)
  61. {
  62. long pens, apens ;
  63.  
  64.     pens = apens = gl->win->ws->xpens[BLACK_PEN] << 8 ;
  65.     pens += gl->win->ws->xpens[WHITE_PEN] ;
  66.     apens += gl->win->ws->xpens[GREEN_PEN] ;
  67.  
  68.     gl->ng->ng_GadgetText = (UBYTE *)title ;
  69.     underkey(title) ;
  70.     gl->ng->ng_Flags = flags ;
  71.  
  72.     // since the font style can be modified several times
  73.     // in a window opening process, this is a reliable way to be sure
  74.     // that the wanted font will be used
  75.  
  76.     gfont = OpenFont(gl->ng->ng_TextAttr) ;
  77.  
  78.     im = (Image *)NewObject(NULL, (UBYTE *)"frameiclass",
  79.         IA_Top,             -1,
  80.         IA_Left,            -2,
  81.         IA_Width,           gl->ng->ng_Width,
  82.         IA_Height,          gl->ng->ng_Height,
  83.         IA_Recessed,        TRUE,
  84.         TAG_DONE) ;
  85.  
  86.     gad = gl->gad = (Gadget *)NewObject(NULL, (UBYTE *)"strgclass",
  87.             GA_Top,                 gl->ng->ng_TopEdge+1,
  88.             GA_Left,                gl->ng->ng_LeftEdge+2,
  89.             GA_Width,               gl->ng->ng_Width-4,
  90.             GA_Height,              gl->ng->ng_Height-2,
  91.             GA_ID,                  id,
  92.             GA_Image,               im,
  93.  
  94.             GA_RelVerify,           TRUE,
  95.  
  96.             GA_Previous,            gl->gad,
  97.             GA_TabCycle,            TRUE,
  98.  
  99.             STRINGA_MaxChars,       15,
  100.             STRINGA_LongVal,        val,
  101.             STRINGA_Pens,           pens,
  102.             STRINGA_ActivePens,     apens,
  103.             STRINGA_Justification,  justify,
  104.             STRINGA_Font,           gfont,
  105.  
  106.             TAG_END) ;
  107.  
  108.     curval = val ;
  109. }
  110.  
  111. number::~number()
  112. {
  113.     if (gad) DisposeObject(gad) ;
  114.     if (im) DisposeObject(im) ;
  115.     if (gfont) CloseFont(gfont) ;
  116. }
  117.  
  118. void number::action(unsigned long classe, unsigned short code)
  119. {
  120.     curval = ((StringInfo *)gad->SpecialInfo)->LongInt ;
  121.     gadget::action(classe, code) ;
  122. }
  123.  
  124. void number::set(long val)
  125. {
  126.     curval = val ;
  127.     SetGadgetAttrs(gad, w, NULL,
  128.         STRINGA_LongVal,    val,
  129.         TAG_END) ;
  130.  
  131. }
  132.  
  133.  
  134. void number::keystroke(BOOL shifted)
  135. {
  136.     ActivateGadget(gad, w, NULL) ;
  137. }
  138.  
  139. @
  140.  
  141.  
  142. 1.2
  143. log
  144. @bug système : MaxChars pose des problèmes -> fixé à 15
  145. test avant cleanup
  146. @
  147. text
  148. @d1 1
  149. d6 1
  150. a6 2
  151.  
  152. #include <cxxproto/intuition.h>
  153. d20 1
  154. a20 1
  155.                STRPTR title,
  156. d32 1
  157. a32 1
  158.     gl->ng->ng_GadgetText = title ;
  159. d36 7
  160. a42 1
  161.     im = (Image *)NewObject(NULL, "frameiclass",
  162. d50 1
  163. a50 1
  164.     gad = gl->gad = (Gadget *)NewObject(NULL, "strgclass",
  165. d68 1
  166. d79 1
  167. @
  168.  
  169.  
  170. 1.1
  171. log
  172. @Initial revision
  173. @
  174. text
  175. @d28 1
  176. a28 1
  177.     pens = apens = gl->win->ws->xpens[BLACK_PEN] << 4 ;
  178. d57 1
  179. a57 1
  180.             STRINGA_MaxChars,       max,
  181. d70 2
  182. a71 2
  183.     DisposeObject(gad) ;
  184.     DisposeObject(im) ;
  185. @
  186.